package com.lagou.boot;

import com.lagou.consumer.RpcConsumer;
import com.lagou.entity.RpcRequest;
import com.lagou.server.IUserService;

/**
 * @author sxnan
 * @className ConsumerBoot
 * @description TODO
 * @date 2020/8/18
 */
public class ConsumerBoot {

    public static void main(String[] args) throws InterruptedException {
//        public class Dancer {
//
//            //tony跳起了舞种名为肚皮舞的舞蹈
//            public void dance(String name,String danceKinds){
//                System.out.println(name+"跳起了舞种名为"+danceKinds+"的舞蹈");
//            }
//        }

        //创建参数对象
        RpcRequest request =  new RpcRequest();
        request.setClassName("com.lagou.server.Dancer");
        request.setMethodName("dance");
        Object[] params = new Object[2];
        params[0]="tony";
        params[1]="肚皮舞";
        request.setParameters(params);
        Class[] classes = new Class[2];
        classes[0]=String.class;
        classes[1]=String.class;
        request.setParameterTypes(classes);

        //1.创建代理对象
        IUserService userService = (IUserService) RpcConsumer.createProxy(IUserService.class, request);
        //2.循环给服务器写数据
        for (int i = 0; i < 100; i++) {
            Thread.sleep(1000);
            System.out.println(userService.sayHello(request));
        }
    }
}
